package com.qdu.topn;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.Job;

//单次学习时长最高的10位
public class TopnDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {


        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(TopnDriver.class);

        job.setMapperClass(TopnMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        job.setReducerClass(TopnReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
        //设置输入和输出目录
        //conf.set("fs.defaultFS", "hdfs://songchao/");
        FileInputFormat.addInputPath(job, new Path("hdfs://songchao:9000/data/user_learn_statistics_total"));
        FileOutputFormat.setOutputPath(job, new Path("hdfs://songchao:9000/output/topn"));

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }

}